Page({
    data: {
        markers: [],
        teacher_list: [],
        copy: !1
    },

    onLoad: function (t) {
        getApp().page.onLoad(this, t), t.mch_id && (this.setData({
            mch_id: t.mch_id
        }), this.getShopData());
    },
    classfenlei: function () {
        var id = this.__data__.mch_id;
        wx.redirectTo({
            url: '/mch/shop-cat/shop-cat?mch_id=' + id,
        })
    },
    shouye: function () {
        var id = this.__data__.mch_id;
        wx.redirectTo({
            url: '/mch/shop/shop?mch_id=' + id,
        })
    },
    jieshao: function () {
        var id = this.__data__.mch_id;
        wx.redirectTo({
            url: '/mch/shop-summary/shop-summary?mch_id=' + id,
        })

      }
    ,  
     
    js: function () {
        var id = this.__data__.mch_id;
        wx.redirectTo({
            url: '/mch/institutional-community/institutional-community?mch_id=' + id,
        })
    },
    zhibo: function () {
        var id = this.__data__.mch_id;
        wx.redirectTo({
            url: '/lives/admin/goods-list/goods-list?mch_id=' + id,
        })
    },

    kfuStart: function () {
        this.setData({
            copy: !0
        });
    },
    kfuEnd: function () {
        this.setData({
            copy: !1
        });
    },
    copyinfo: function (t) {
        getApp().core.setClipboardData({
            data: t.target.dataset.info,
            success: function (t) {
                getApp().core.showToast({
                    title: "复制成功！",
                    icon: "success",
                    duration: 2e3,
                    mask: !0
                });
            }
        });
    },
    callPhone: function (t) {
        getApp().core.makePhoneCall({
            phoneNumber: t.target.dataset.info
        });
    },
    getShopData: function () {
        var a = this;
        getApp().core.showLoading({
            title: "加载中"
        }), getApp().request({
            url: getApp().api.mch.shop_introduce,
            data: {
                mch_id: a.data.mch_id
            },
            success: function (t) {
                if (0 == t.code) {
                    var e = t.data.shop,
                        o = [{
                            iconPath: "/mch/images/img-map.png",
                            id: 0,
                            width: 20,
                            height: 43,
                            longitude: e.longitude,
                            latitude: e.latitude
                        }];
                    a.setData({
                        markers: o,
                        shop: t.data.shop,
                        teacher_list: t.data.teacher_list,
                        cs_icon: t.data.shop.cs_icon
                    });
                }
            },
            complete: function () {
                getApp().core.hideLoading(), a.setData({
                    loading: !1
                });
            }
        });
    },
    map_power: function () {
        var o = this;
        getApp().getConfig(function (t) {
            var e = o.data.shop;
            void 0 !== e ? o.map_goto(e) : getApp().core.getSetting({
                success: function (t) {
                    t.authSetting["scope.userLocation"] ? o.map_goto(e) : getApp().getauth({
                        content: "需要获取您的地理位置授权，请到小程序设置中打开授权！",
                        cancel: !1,
                        author: "scope.userLocation",
                        success: function (t) {
                            t.authSetting["scope.userLocation"] && o.map_goto(e);
                        }
                    });
                }
            });
        });
    },
    map_goto: function (t) {
        getApp().core.openLocation({
            latitude: parseFloat(t.latitude),
            longitude: parseFloat(t.longitude),
            address: t.address
        });
    },
    onClickImage: function (e) {
        var i, that = this,picArr = [];
        var index = e.currentTarget.dataset.index;
        var type = e.currentTarget.dataset.type;
        if(type==0){
            for( i in that.data.teacher_list){
                picArr.push(that.data.teacher_list[i].pic);
            }
        }else if(type==1){
            for( i in that.data.shop.edu ){
                picArr.push(that.data.shop.edu[i].pic);
            }
        }else if(type==2){
            for( i in that.data.shop.brief ){
                picArr.push(that.data.shop.brief[i].pic);
            }
        }else if(type==3){
            picArr=[that.data.shop.business];
        }else if(type==4){
            // for( i in that.data.shop.certificate ){
                picArr=that.data.shop.certificate;
            // }
        }
        
        wx.previewImage({
            urls: picArr,
            current: picArr[index]
        });
    },
    onClick: function () {
        wx.navigateTo({
            url: '/pages/search/search?mch_id=' + this.data.mch_id,
        })
    },
    onShareAppMessage: function () {
        getApp().page.onShareAppMessage(this);
        var t = this;
        return {
            path: "/mch/shop/shop?user_id=" + getApp().getUser().id + "&mch_id=" + t.data.mch_id + '&store_id=' + (wx.getStorageSync("store_id") ? wx.getStorageSync("store_id") : 0),
            title: t.data.shop ? t.data.shop.name : "机构首页"
        };
    }
});